<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <!-- 1、引入依赖 -->
  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

  <div id="app"></div>

  <!-- 2、编写react代码 -->
  <script type="text/babel">

    class App extends React.Component {
      constructor(props){
        super(props)
        this.state = {
          message: 'hello world'
        }

      }


      // 所有组件必须实现render方法
      render() {
        const { message } = this.state


        // 必须用return返回
        return (
          // {}语法  里面可以是表达式
          <div>
            <div className="header">
              <h1 title="标题">标题</h1>
            </div>
            <div className="content">
              <h2>页面的内容</h2>
              <button>+1</button>
              <a href="http://www.baidu.com">百度一下</a>
            </div>
            <div className="footer">
              <p>底部内容</p>
            </div>
          </div>
        )
      }
    }

    // 上面jsx代码转换成React.createElement后

    React.createElement('div', null, 'header', 'content', 'footer')

    // "header" 又是一个 React.createElement('div', {className: "header"}, 'h2', 'button', 'a')

    // classic /*#__PURE__*/表示React.createElement纯函数

    /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
      className: "header"
      }, /*#__PURE__*/React.createElement("h1", {
        title: "\u6807\u9898"
      }, "\u6807\u9898")), /*#__PURE__*/React.createElement("div", {
        className: "content"
      }, /*#__PURE__*/React.createElement("h2", null, "\u9875\u9762\u7684\u5185\u5BB9"), /*#__PURE__*/React.createElement("button", null, "+1"), /*#__PURE__*/React.createElement("a", {
        href: "http://www.baidu.com"
      }, "\u767E\u5EA6\u4E00\u4E0B")), /*#__PURE__*/React.createElement("div", {
        className: "footer"
      }, /*#__PURE__*/React.createElement("p", null, "\u5E95\u90E8\u5185\u5BB9")));


      // automatic
      import { jsx as _jsx } from "react/jsx-runtime";
      import { jsxs as _jsxs } from "react/jsx-runtime";
      /*#__PURE__*/_jsxs("div", {
        children: [/*#__PURE__*/_jsx("div", {
          className: "header",
          children: /*#__PURE__*/_jsx("h1", {
            title: "\u6807\u9898",
            children: "\u6807\u9898"
          })
        }), /*#__PURE__*/_jsxs("div", {
          className: "content",
          children: [/*#__PURE__*/_jsx("h2", {
            children: "\u9875\u9762\u7684\u5185\u5BB9"
          }), /*#__PURE__*/_jsx("button", {
            children: "+1"
          }), /*#__PURE__*/_jsx("a", {
            href: "http://www.baidu.com",
            children: "\u767E\u5EA6\u4E00\u4E0B"
          })]
        }), /*#__PURE__*/_jsx("div", {
          className: "footer",
          children: /*#__PURE__*/_jsx("p", {
            children: "\u5E95\u90E8\u5185\u5BB9"
          })
        })]
      });

    ReactDOM.render(<App/>, document.getElementById('app')) 
  </script>
</body>
</html>